package mysql

import "gorm.io/gorm"

type User2 struct {
	gorm.Model
	Name   string `gorm:"type:varchar(10);comment:用户名"`
	Tel    string `gorm:"type:char(11);comment:手机号"`
	Status int    `gorm:"type:int(1);comment:用户状态:0-正常，1-冻结"`
}

func (u *User2) UpdateUserStatus(UserId, Status int) error {
	return DB.Model(&u).Where("id=?", UserId).Update("status", Status).Error
}

type Goods2 struct {
	gorm.Model
	GoodsName  string  `gorm:"type:varchar(10);comment:商品名称"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);comment:商品价格"`
	GoodsNum   int     `gorm:"type:int(10);comment:商品库存"`
	GoodsImg   string  `gorm:"type:varchar(255);comment:商品封面"`
	Status     int     `gorm:"type:int(1);comment:商品状态:0-审核通过，1-审核失败"`
}

func (g *Goods2) GoodsAdd() error {
	return DB.Create(&g).Error
}

type Order2 struct {
	gorm.Model
	UserId      int     `gorm:"type:int(10);comment:用户id"`
	GoodsId     int     `gorm:"type:int(10);comment:商品id"`
	OrderSn     string  `gorm:"type:char(36);comment:订单号"`
	OrderStatus int     `gorm:"type:int(1);comment:订单状态:0-已支付，1-未支付"`
	PayType     int     `gorm:"type:int(1);comment:支付方式:0-微信，1-支付宝"`
	Amount      float64 `gorm:"type:decimal(10,2);comment:订单金额"`
	GoodsName   string  `gorm:"type:varchar(20);comment:商品名称"`
	GoodsImg    string  `gorm:"type:varchar(255);comment:商品封面"`
}
